<template>
  <basePage :show-tabbar="false" :page-params="pageParams">
    <view class="content">
      <image style="position: absolute; height: 100%; width: 100%" src="/static/image/home_page.jpg" />
    </view>
    <!-- 关注微信公众号 -->
    <!--     #ifdef MP-WEIXIN-->
    <official-account style="position: fixed; width: 100%; bottom: 0px;" />
    <!--    #endif-->
  </basePage>
</template>
<script>
import basePage from '@/components/base-page'
import { pushMeber } from '@/api/login.js'
export default {
  components: {
    basePage,
  },
  data() {
    return {
      title: 'Index',
      pageParams: {
        // state: 'ERROR',
        emptyTitle: '信号可能跑到外星球了哦～',
        errorTitle: '请求失败',
        showButton: true
      },
    }
  },
  onLoad(option) {
    // #ifdef MP-ALIPAY
    if (uni.getStorageSync('inviteCode')) {
      this.bindMember(uni.getStorageSync('inviteCode'))
    }
    // #endif
    // #ifdef MP-WEIXIN
    if (option.q) {
      const src = decodeURIComponent(option.q)
      if (src.includes('inviteCode')) {
        const inviteCode = src.match(/inviteCode=(\S*)/)[1]
        uni.setStorageSync('inviteCode', inviteCode)
        this.bindMember(inviteCode)
      }
    }
    // #endif

    // if (!!uni.getStorageSync('inviteCode')) {
    //   this.bindMember(uni.getStorageSync('inviteCode'))
    // }
  },
  methods: {
    bindMember(inviteCode) {
      const params = {
        loginAccount: this.vuex_accountInfo.loginAccount,
        inviteCode: inviteCode
      }
      pushMeber(params).then((res) => {
        console.log(res)
      })
    }
  }
}
</script>

<style>

</style>
